<template>
    <div class="article-lists">
        <el-card class="!border-none" shadow="never">
			<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
				<el-form-item label="审核状态">
					<el-select class="w-60" v-model="queryParams.status" placeholder="请选择" clearable filterable>
						<el-option label="未处理" :value="0"/>
						<el-option label="已处理" :value="1"/>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="resetPage">查询</el-button>
					<el-button @click="resetParams">重置</el-button>
				</el-form-item>
			</el-form>
		</el-card>

        <el-card class="!border-none" shadow="never">
            <el-table size="large" v-loading="pager.loading" :data="pager.lists">
                <el-table-column label="序号" type="index" :index="indexAdd" min-width="120" />
                <el-table-column label="申请城市" prop="area_id" min-width="110" >
					<template #default="{ row }">
						<span v-if="row.area_id" v-city="row.area_id"></span>
						<span v-else>平台</span>
					</template>
				</el-table-column>
                <el-table-column label="场地类型" min-width="220" prop="place_type">
                    <template #default="{row}">
                        <span v-if="row.place_type == 1">共享办公（场地有工位出租）</span>
                        <span v-if="row.place_type == 2">签约/洽谈中心（为同行提供免费洽谈场地）</span>
                    </template>
                </el-table-column>
                <el-table-column label="联系人" prop="link_person_name" min-width="180" />
                <el-table-column label="手机号" prop="link_person_phone" min-width="140" />
                <el-table-column label="场地地址" min-width="180" prop="location_name"/>
                <el-table-column label="面积" min-width="160" show-tooltip-when-overflow>
                  <template #default="{row}">
                      {{ row?.size +'m²'}}
                  </template>
                </el-table-column>
                <el-table-column label="状态" prop="status" min-width="100" >
                    <template #default="{row}">
                        <span v-if="row.status == 0">待审核</span>
                        <span v-if="row.status == 1">审核通过</span>
                        <span v-if="row.status == 2">审核驳回</span>
                    </template>
                </el-table-column>
                <el-table-column label="备注" prop="remark" min-width="200" />
                <el-table-column label="操作" width="180" fixed="right">
                    <template #default="{ row }">
                        <el-button
                            v-perms="['office.office_place/checkPlaceApply']"
                            type="primary"
                            link
                        >
                            <router-link
                                :to="{
                                    path: getRoutePath('office.office_place/checkPlaceApply'),
                                    query: {
                                        ...row
                                    }
                                }"
                            >
                                {{ row.status == 0 ?'审核':'详情'}}
                            </router-link>
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>
<script lang="ts" setup name="officePlaceLists">
import {placeApplyList} from '@/api/office/officePlace'
import { usePaging } from '@/hooks/usePaging'
import { getRoutePath } from '@/router'
import feedback from '@/utils/feedback'

const queryParams = reactive({
    area_id: '',
    status: ''
})
import useAppStore from '@/stores/modules/app'
const useApp = useAppStore()
const optionCity:any = useApp.optionCity;

// 切页序号变化
const indexAdd = (index: number) => {
    const page = pager.page // 当前页码
    const pagesize = pager.size // 每页条数
    return index + 1 + (page - 1) * pagesize
}
const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: placeApplyList,
    params: queryParams
})

onActivated(() => {
    getLists()
})

getLists()
</script>
